{% extends "./base.html" %}
{% url 'loaduser-view' as loaduser_url %}

{% block content %}
<script type="text/javascript" src="/static/js/wmadmin.js"></script>
        <div class="header">

            <h1 class="page-title">供应商管理</h1>
                    <ul class="breadcrumb">
            <li><a href="/">首页</a> </li>


            <li class="active">供应商信息</li>
                        <input class="layui-btn layui-btn-mini" type="button" name="Submit" onclick="javascript:history.back(-1);" value="返回上一页">
        </ul>

        </div>
        <div class="main-content">

<div class="btn-toolbar list-toolbar">

 <form  role="form" method="get" action="{% url 'suppliersearch-view' %}" style="float: left">
 {% csrf_token %}
    <input placeholder="请输入搜索关键词" type="text"  class="form-control" id="s" name="word"  style="width:200px;float: left;">




 <button class="btn btn-primary" >搜 索</button>
     {% if count %}
     一共搜索到 <a style="color: red">{{ count }}</a> 条记录 |  {% endif %}共<a style="color: red"> {{ allcount }} </a>条

</form>
<div style="float: right">


    <a href="{% url 'addsupplier-view' %}" class="btn btn-primary"><i class="fa fa-plus"></i> 添加供应商</a>

    <a href="{% url 'upsupplier-view' %}" class="btn btn-default">导入数据</a>

    <input id="openexcelfile" type="file" name="openexcelfile" style="display: none;" />

    <a href="{% url 'loadsupplier-view' %}" class="btn btn-default">导出数据</a>
      <input id="yourinputname" type="file" name="yourinputname" value="上传" style="display: none;" />
    </div>
  <div class="btn-group">
  </div>
</div>
<table class="table table-striped table-bordered table-hover">
  <thead>
    <tr>
      <th width="15%">公司名称</th>
      <th width="20%">公司地址</th>
        <th width="10%">公司电话</th>
        <th width="15%">公司网站</th>
         <th width="10%">联系人</th>
         <th width="10%">联系电话</th>
        <th width="15%">联系人邮箱</th>



         <th>操作</th>

    </tr>
  </thead>
  <tbody>
  {% with obj_list as supplier_list %}

  {% if supplier_list %}
      {% for obj in supplier_list %}
           <tr>
      <td><a href="/supplier/{{ obj.id }}" title="点击修改此条信息"> {{ obj.corporate_name }}</a></td>
      <td>{{ obj.corporate_adress }}</td>
      <td> {% if obj.corporate_phone %}{{ obj.corporate_phone }}{% else %}{{ '' }}{% endif %}</td>
      <td> {% if obj.corporate_site %}<a href="{{ obj.corporate_site }}" target="{{ obj.id }}_black" title="点击打开网站">{{ obj.corporate_site }}</a>{% else %}{{ '' }}{% endif %}</td>
      <td> {{ obj.contect_name }}</td>
      <td> {{ obj.contect_phone }}</td>
      <td>{% if obj.contect_email %}<a href="mailto:{{ obj.contect_email }}" title="点击发送邮件给对方">{{ obj.contect_email }}</a>{% else %}{{ '' }}{% endif %}</td>


      <td>
          <a href="/supplier/{{ obj.id }}" title="修改"><i class="fa fa-pencil"></i></a>&nbsp;

    <a href="#delModal{{ obj.id }}" role="button" data-toggle="modal" title="删除"><i class="fa fa-trash-o"></i></a>


    <div class="modal small fade" id="delModal{{ obj.id }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

<form id="delmodelform{{ obj.id }}" method="post" action="/delsupplier/{{ obj.id }}/" >
 {% csrf_token %}
  <div class="modal-dialog">

    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <a style="color:red;font-size: x-large">删除资产</a>
        </div>

        <div class="modal-body">
            <p class="error-text"><i class="fa fa-warning modal-icon"></i>您确定要删除供应商  <a style="color: red">{{ obj.corporate_name }}</a><br>如要恢复请登录管理员后台操作</p>
        </div>

        <div class="modal-footer">
            <button  class="btn btn-danger" data-dismiss="modal" onclick="submitForm('{{ obj.id }}');">Delete</button>
            <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>

        </div>
      </div>
    </div>
</form>
</div>


      </td>
    </tr>
      {% endfor %}


  {% endif %}
{% endwith %}
  </tbody>

</table>





<script>

  function submitForm(e) {

                document.getElementById("delmodelform"+e).submit();

     }

function del_userjs()
{
    var getid = document.getElementById("asset").innerHTML;

    layer.confirm('确认删除资产：（'+getid+"）    吗？", {icon: 3, title:'提示:删除后不可恢复！'}, function(index){
  //do something
  $("#del_user").submit();
  layer.close(index);
});





}
</script>

<!--分页 -->

        {% if obj_list %}
            <div  style="position:absolute;bottom:0px;">
        {% include 'include/pagination.html' %}
            </div>
        {% endif %}




</div>

{% endblock %}